
DEFINE MISSIONS 1              // Total Missions Available
DEFINE MISSION 0 AT @MISSN_16  
  

DEFINE EXTERNAL_SCRIPTS 0 

DEFINE UNKNOWN_EMPTY_SEGMENT 0

DEFINE UNKNOWN_THREADS_MEMORY 500

{$VERSION 3.1.0027}
var
 $PLAYER_CHAR: Player
end // var 
//Main thread starts here
03A4: name_thread 'MAIN' 
//Set the screen BLACK immediately
016A: fade 0 time 0           
01F0: set_max_wanted_level_to 6 
0111: toggle_wasted_busted_check 0 
00C0: set_current_time_hours_to 8 minutes_to 0 
//Loads Tenpenny as #SPECIAL01 or 290
023C: load_special_actor 'TENPEN' as 1 
//Create Player at Station
Camera.SetAtPos(-1630.425, 725.9995, 14.0557)
$PLAYER_CHAR = Player.Create(#NULL, 2016.0144, 1105.6646, 10.8203)
Player.Build($PLAYER_CHAR)
//Changes the player to ped model 290 Tenpenny
09C7: change_player $PLAYER_CHAR model_to 290 
01F5: $PLAYER_ACTOR = create_player_actor $PLAYER_CHAR 
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group 

01B6: set_weather 1 
0001: wait 0 ms 
01B4: toggle_player $PLAYER_CHAR can_move false //We shut down control for the cameras to work 
04BB: select_interior 0 
0629: change_integer_stat 181 to 4 
016C: restart_if_wasted_at 2016.0144 1105.6646 10.8203 angle 90.0 town_number 0 
016D: restart_if_busted_at 2016.0144 1105.6646 10.8203 angle 90.0 town_number 0 
// Note: your missions have to use the variable defined here
0180: set_on_mission_flag_to $ONMISSION 
$ONMISSION = 0 
0004: $DEFAULT_WAIT_TIME = 250
03E6: remove_text_box 
// START GAME
//start_mission 0                 //First Mission and Only Mission
$CRASH_MARKER = Marker.CreateIconAndSphere(16, 2026.8145, 1109.2987, 10.813)
016A: fade 1 time 500
wait 1000
01B4: toggle_player $PLAYER_CHAR can_move true
 
:MAIN_LOOP
0001: wait $DEFAULT_WAIT_TIME ms
00BF: $TIME_HOURS = current_time_hours, $TIME_MINS = current_time_minutes
//This code allows restart of mission 
if and
  $ONMISSION == 0               //No current mission and enters the sphere
  00ED: actor $PLAYER_ACTOR 0 near_point 2026.8145 1109.2987 radius 1.0 1.0 on_foot 
then
    016A: fade 0 time 500 
    0001: wait 1000 ms
    Marker.Disable($CRASH_MARKER)   //Turn off the marker on the map and the red ring
    start_mission 0 
end

0002: jump @MAIN_LOOP 
//Tenpenny is out gambling when an Elvis robs the casino. After you chase him to the airport you climb aboard his
//escape jet.  But are surprised to find he has planned to dive from the plane and make it look like he blew up.
//As you both dive to the ground he has the only parachute.

:MISSN_16
thread 'MISSN_16' 

gosub @MISSN_16_108             // Start Mission
            
if 
    wasted_or_busted            
then
    $CRASH_MARKER = Marker.CreateIconAndSphere(16, 2026.8145, 1109.2987, 10.813)
end
gosub @MISSN_16_2720             // End Mission Destroy All
end_thread 

:MISSN_16_108 
Player.CanMove($PLAYER_CHAR) = False
$ONMISSION = 1

//Elvis Leaves the Building
//PART 1 Load Models
Model.Load(#TRASH)
Model.Load(#VHMYELV)          
Model.Load(#MRWHOOP) 
04ED: load_animation "CASINO" 
     
038B: load_requested_models 

//Check for Models Loading
:MISSN_16_110
wait 0
if and
Model.Available(#TRASH)
Model.Available(#VHMYELV)
Model.Available(#MRWHOOP)
04EE:   animation "CASINO" loaded 
jf @MISSN_16_110 

:MISSN_16_120
054C: use_GXT_table 'JABM16' 

//Trash getaway vehicle 
101@ = Car.Create(#TRASH, 2039.9041, 1123.9319, 10.6719)
Car.Angle(101@) = 0.0             
102@ = Car.Create(#MRWHOOP, 2040.033, 1110.996, 10.6719)
Car.Angle(102@) = 0.0          
02A3: enable_widescreen 1 
04BB: select_interior 1
04F9: set_interior 1 color_to 0 
Camera.SetAtPos(2268.0474, 1606.5676, 1006.1797)
0860: link_actor $PLAYER_ACTOR to_interior 1 

Actor.PutAt($PLAYER_ACTOR, 2268.0474, 1606.5676, 1006.1797 )
Actor.Angle($PLAYER_ACTOR) = 276.0
Player.CanMove($PLAYER_CHAR) = false
067E: put_camera_on_actor $PLAYER_ACTOR with_offset 1.0 -5.0 1.5 point_to_actor $PLAYER_ACTOR 0.0 mode 2 
009A: 111@ = create_actor_pedtype 4 model #VHMYELV at 2280.6106 1567.7157 1008.3594

0615: define_AS_pack_begin 15@ 
0812: AS_actor -1 perform_animation "SLOT_IN" IFP_file "CASINO" 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1 // versionB 
0812: AS_actor -1 perform_animation "SLOT_PLYR" IFP_file "CASINO" 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1 // versionB 
0812: AS_actor -1 perform_animation "SLOT_LOSE_OUT" IFP_file "CASINO" 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1 // versionB 
0812: AS_actor -1 perform_animation "SLOT_BET_01" IFP_file "CASINO" 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1 // versionB 
0616: define_AS_pack_end 15@ 
0618: assign_actor $PLAYER_ACTOR to_AS_pack 15@ 
061B: remove_references_to_AS_pack 15@ 

0615: define_AS_pack_begin 15@ 
0603: AS_actor -1 goto 2280.8862 1629.7312 1008.3663 mode 6 timelimit -1  
0603: AS_actor -1 goto 2244.3372 1630.8364 1008.3594 mode 6 timelimit -1  
0616: define_AS_pack_end 15@ 
0618: assign_actor 111@ to_AS_pack 15@ 
061B: remove_references_to_AS_pack 15@ 

016A: fade 1 time 2000 
:MISSN_16_FADEIN1
wait 0
if
not fading
jf @MISSN_16_FADEIN1

wait 8000
067E: put_camera_on_actor $PLAYER_ACTOR with_offset 0.0 -0.5 1.5 point_to_actor 111@ 0.0 mode 2 
00BC: show_text_highpriority GXT 'FE01' time 5000 flag 1 
03CF: load_wav 44427 as 1 
gosub @MISSN_16_PLAYSND
00BC: show_text_highpriority GXT 'FE02' time 5000 flag 1  
03CF: load_wav 44428 as 1 
gosub @MISSN_16_PLAYSND
0850: AS_actor $PLAYER_ACTOR follow_actor 111@
00BC: show_text_highpriority GXT 'FE03' time 6000 flag 1  
wait 2000
067E: put_camera_on_actor $PLAYER_ACTOR with_offset 0.0 -3.0 1.0 point_to_actor $PLAYER_ACTOR 0.0 mode 2 
wait 3000
016A: fade 0 time 0 
:MISSN_16_FADEOUT1
wait 0
if
not fading
jf @MISSN_16_FADEOUT1   
//Elvis and Tenpenny on street
Actor.DestroyInstantly(111@)
04BB: select_interior 0
0860: link_actor $PLAYER_ACTOR to_interior 0 
//Place Tenpenny
Actor.PutAt($PLAYER_ACTOR, 2016.0144, 1105.6646, 10.8203 )
Actor.Angle($PLAYER_ACTOR) = 270.0
009A: 111@ = create_actor_pedtype 4 model #VHMYELV at 2026.8145 1109.2987 10.813
0446: set_actor 111@ immune_to_headshots true 
0187: 90@ = create_marker_above_actor 111@ 
07E0: set_marker 90@ type_to 0
0165: set_marker 90@ color_to 0 
105@ = 0
02A3: enable_widescreen 0 

Player.CanMove($PLAYER_CHAR) = true
Camera.Restore_WithJumpCut
Camera.SetBehindPlayer

:MISSN_16_150
//Start Mission Play
05CB: AS_actor 111@ enter_car 101@ as_driver -1 ms
wait 500
05CB: AS_actor $PLAYER_ACTOR enter_car 102@ as_driver -1 ms

016A: fade 1 time 2000 
:MISSN_16_160
wait 0
if
not fading
jf @MISSN_16_160

//Elvis Enters Trash
:MISSN_16_170  
wait 0
if
Actor.InCar(111@, 101@)
jf @MISSN_16_170
05D1: AS_actor 111@ drive_car 101@ to 2040.348 1267.4064 10.2712 speed 20.0 3 model #TRASH 3
//Follow Elvis don't bust him in public or you won't get the cash he stole.
//Main Loop
:MISSN_16_190
wait 0
if  and 
    105@ == 0 
    00EE:   actor 111@ 0 near_point 2040.348 1267.4064 radius 5.0 5.0 in_car 
then
    105@ += 1                             
    05D1: AS_actor 111@ drive_car 101@ to 1767.0226 1276.0172 12.3319 speed 35.0 3 model #TRASH 3
end
if  and 
    105@ == 1 
    00EE:   actor 111@ 0 near_point 1767.0226 1276.0172 radius 5.0 5.0 in_car 
then
    105@ += 1    
    05D1: AS_actor 111@ drive_car 101@ to 1734.1145 1295.1716 10.2958 speed 10.0 1 model #TRASH 1
    00BC: show_text_highpriority GXT 'FE04' time 5000 flag 1  
end
if  and 
    105@ == 2 
    00EE:   actor 111@ 0 near_point 1734.1145 1295.1716 radius 5.0 5.0 in_car 
then
    105@ += 1    
    05D1: AS_actor 111@ drive_car 101@ to 1713.254 1435.0334 10.7802 speed 25.0 1 model #TRASH 1
    
end
if  and 
    105@ == 3
    00EE:   actor 111@ 0 near_point 1731.928 1354.6085 radius 5.0 5.0 in_car 
then
    105@ += 1    
    05D1: AS_actor 111@ drive_car 101@ to 1713.254 1435.0334 10.7802 speed 25.0 1 model #TRASH 1
    00BC: show_text_highpriority GXT 'FE05' time 5000 flag 1  
end
if  and 
    105@ == 4 
    00EE:   actor 111@ 0 near_point 1713.254 1435.0334 radius 5.0 5.0 in_car 
then
    105@ += 1    
    05D1: AS_actor 111@ drive_car 101@ to 1729.7987 1589.0435 10.5291 speed 20.0 1 model #TRASH 1
end
if  and 
    105@ == 5
    00EE:   actor 111@ 0 near_point 1729.7987 1589.0435 radius 5.0 5.0 in_car 
then
    fade 0 1000
    jump @MISSN_16_200
end
//Get the positions of the two drivers
00A0: store_actor $PLAYER_ACTOR position_to $TEMPVAR_FLOAT_a $TEMPVAR_FLOAT_b $TEMPVAR_FLOAT_c 
00A0: store_actor 111@ position_to $TEMPVAR_FLOAT_x $TEMPVAR_FLOAT_y $TEMPVAR_FLOAT_z 
0509: 17@ = distance_between_XY $TEMPVAR_FLOAT_a $TEMPVAR_FLOAT_b and_XY $TEMPVAR_FLOAT_x $TEMPVAR_FLOAT_y

if or
Actor.Dead(111@)
17@ > 150.0
jf @MISSN_16_190
00BC: show_text_highpriority GXT 'FE06' time 5000 flag 1  

gosub @MISSN_16_2600  //Lost him...
return

:MISSN_16_200
wait 0
if
not fading
jf @MISSN_16_200
//Homemade Cut Scene
015F: set_camera_position 1324.0593 1589.7377 11.8203 rotation 0.0 0.0 0.0 
Camera.PointAt(1320.3667, 1588.0, 10.82, 2)
//Get the actors out of cars
if
not Actor.Driving(111@)
0633: AS_actor 111@ exit_car 
if
not Actor.Driving($PLAYER_ACTOR)
0633: AS_actor $PLAYER_ACTOR exit_car 
:MISSN_16_210
wait 0
if and
not Actor.Driving($PLAYER_ACTOR)
not Actor.Driving(111@)
jf @MISSN_16_210

0164: disable_marker 90@
Model.Destroy(#TRASH)        
Model.Destroy(#MRWHOOP) 

//Inside the Jet
04BB: select_interior 1 
0860: link_actor $PLAYER_ACTOR to_interior 1 
0860: link_actor 111@ to_interior 1 
015F: set_camera_position 1.8004 26.3199 1199.5937 rotation 0.0 0.0 0.0 
Camera.PointAt(1.5782, 33.5129, 1199.5937, 2)
Actor.PutAt($PLAYER_ACTOR, 1.8004, 26.3199, 1199.5937)
Actor.Angle($PLAYER_ACTOR) = 357.0
Actor.PutAt(111@, 1.5782, 33.5129, 1199.5937)
Actor.Angle(111@) = 183.0
Player.CanMove($PLAYER_CHAR) = false
Camera.Restore_WithJumpCut
Camera.SetBehindPlayer
wait 1500
016A: fade 1 time 0 
:MISSN_16_250
wait 0
if
not fading
jf @MISSN_16_250

00BC: show_text_highpriority GXT 'FE07' time 5000 flag 1  
03CF: load_wav 44422 as 1 
gosub @MISSN_16_PLAYSND
00BC: show_text_highpriority GXT 'FE08' time 5000 flag 1  
03CF: load_wav 44423 as 1 
gosub @MISSN_16_PLAYSND
00BC: show_text_highpriority GXT 'FE09' time 5000 flag 1  
03CF: load_wav 44424 as 1 
gosub @MISSN_16_PLAYSND
00BC: show_text_highpriority GXT 'FE10' time 5000 flag 1  
03CF: load_wav 44425 as 1 
gosub @MISSN_16_PLAYSND
00BC: show_text_highpriority GXT 'FE11' time 5000 flag 1  
03CF: load_wav 44426 as 1 
gosub @MISSN_16_PLAYSND
016A: fade 0 time 0 
:MISSN_16_260
wait 0
if
not fading
jf @MISSN_16_260
04BB: select_interior 0 
0860: link_actor $PLAYER_ACTOR to_interior 0 
0860: link_actor 111@ to_interior 0 

//The Long Fall
//PART 2 Load Models
Model.Load(#SHAMAL)     
Model.Load(#GUN_PARA)      
038B: load_requested_models 

//Check for Models Loading
:MISSN_16_2110
wait 0
if and
Model.Available(#SHAMAL)
Model.Available(#GUN_PARA)
jf @MISSN_16_2110 
                                                    
:MISSN_16_2120
//Lear Jet set to ALT 3460.889 10 meters above Tenpenny 
101@ = Car.Create(#SHAMAL, 700.5404, 1191.4452, 3460.889)
Car.Angle(101@) = 270.0             //Heading West
Car.Health(101@) = 200              //Badly Damaged on Fire

//Elvis 100 meters below Tenpenny
Actor.PutAt(111@, 600.5404, 1050.4452, 3350.889)
0446: set_actor 111@ immune_to_headshots 0 
0187: 90@ = create_marker_above_actor 111@ 
07E0: set_marker 90@ type_to 0
0165: set_marker 90@ color_to 0 
17@ = Object.Create(#PARACHUTE, 600.5404, 1050.4452, 3350.889)
069B: attach_object 17@ to_actor 111@ with_offset 0.0 0.0 0.0 rotation 0.0 0.0 0.0 
0750: set_object 17@ visibility 0 

//Place Tenpenny
Actor.PutAt($PLAYER_ACTOR, 680.5404, 1191.4452, 3450.889 )
Actor.Angle($PLAYER_ACTOR) = 0.0

:MISSN_16_2150
//Start Mission Play
04ED: load_animation "PARACHUTE" 
0812: AS_actor 111@ perform_animation "FALL_SKYDIVE" IFP_file "PED" 1.0 loopA 1 lockX 0 lockY 0 lockF 0 time -2 
Player.CanMove($PLAYER_CHAR) = true
Camera.Restore_WithJumpCut
Camera.SetBehindPlayer
016A: fade 1 time 1000 
:MISSN_16_2160
wait 0
if
not fading
jf @MISSN_16_2160
03E5: show_text_box 'FE12'  
0@ = 0
07D5: set_car 101@ velocity_in_direction_XYZ 5.0 0.0 0.0 rotation_velocitiesXY 1.0 0.0 unk 0.0 

 //Main Loop
:MISSN_16_2190
wait 0
//Tenpenny skydives without parachute
0812: AS_actor $PLAYER_ACTOR perform_animation "FALL_SKYDIVE" IFP_file "PED" 1.0 loopA 1 lockX 0 lockY 0 lockF 0 time -2 
083D: get_actor $PLAYER_ACTOR velocity_in_direction_XYZ $1507 $1508 $1509 
0819: 6@ = actor 111@ distance_from_ground 
0819: 7@ = actor $PLAYER_ACTOR distance_from_ground 
//ALT check less than 20 meters from ground we cut the wind sound.
if 
  7@ > 20.0 
else_jump @MISSN_16_2200 
097A: play_audio_at -1000.0 -1000.0 -1000.0 event 1037 
:MISSN_16_2200
//check the Player's rotation 
1@ = Actor.Angle($PLAYER_ACTOR) 
//Rotation using input from either pad, stick or keyboard.
0494: get_joystick 0 data_to 10@ 11@ 12@ 12@ 
if 
  10@ > 0 
then
1@ -= 2.0
end
if 
  0 > 10@ 
then
1@ += 2.0
end
//keeps degrees on track 0.0 to 359.99
if 1@ < 0.0 
then
1@ += 360.0
end 
if 1@ > 360.0 
then
1@ -= 360.0
end
Actor.Angle($PLAYER_ACTOR) = 1@

//Get the positions of the two divers
00A0: store_actor $PLAYER_ACTOR position_to $TEMPVAR_FLOAT_a $TEMPVAR_FLOAT_b $TEMPVAR_FLOAT_c 
00A0: store_actor 111@ position_to $TEMPVAR_FLOAT_x $TEMPVAR_FLOAT_y $TEMPVAR_FLOAT_z 
//Check distance to grab chute from Elvis.
050A: 3@ = distance_between_XYZ $TEMPVAR_FLOAT_a $TEMPVAR_FLOAT_b $TEMPVAR_FLOAT_c and_XYZ $TEMPVAR_FLOAT_x $TEMPVAR_FLOAT_y $TEMPVAR_FLOAT_z  
if 
3@ < 3.0   //Less than 3 meters = about 9.5 feet
then 
    01B2: give_actor $PLAYER_ACTOR weapon 46 ammo 1  
    01B9: set_actor $PLAYER_ACTOR armed_weapon_to 46 
    jump @MISSN_16_2300  //Finish the mission by landing.
end 
//This part in the original skydiving script was done with complexed math. 
//I made mine simplistic, since I am simple.
//1@ is the direction your body is rotated in degrees.
02F6: $TEMPVAR_FLOAT_1 = cosine 1@ 
02F7: $TEMPVAR_FLOAT_2 = sine 1@ 
$TEMPVAR_FLOAT_1 *= -1.0
//Increase descent
if 
11@ < 0
then
$1509 -= 2.0
end
//Decrease descent
if and
11@ > 0 
$1509 < -10.0         //Keeps you from going up or doing a Cris Angel mind freak
then
$1509 += 2.0
end
//Sprint button moves you forward
if 
00E1:   player 0 pressed_key 16 
then
0059: $1507 += $TEMPVAR_FLOAT_1 
0059: $1508 += $TEMPVAR_FLOAT_2 
end
//Move Tenpenny the direction needed
083C: set_actor $PLAYER_ACTOR velocity_in_direction_XYZ $1507 $1508 $1509  
//Repeat until Elvis pulls the chute at 200.0
if 
not 6@ > 200.0
jf @MISSN_16_2190
//Elvis chute opens and you fall down
0750: set_object 17@ visibility 1
0812: AS_actor $PLAYER_ACTOR perform_animation "FALL_FRONT" IFP_file "PED" 1.0 loopA 1 lockX 0 lockY 0 lockF 0 time 250 // versionB 
0812: AS_actor 111@ perform_animation "PARA_OPEN" IFP_file "PARACHUTE" 8.0 loopA 0 lockX 0 lockY 0 lockF 1 time -2 // versionB 
083C: set_actor 111@ velocity_in_direction_XYZ -1.0 0.0 0.0
wait 3000
gosub @MISSN_16_2600  //Splat!
  
0925: restore_camera_to_user_defined 
Camera.SetBehindPlayer
Player.CanMove($PLAYER_CHAR) = True
Camera.Restore_WithJumpCut
return   //End Thread

:MISSN_16_2300
//At this point we return both charaters to free falling. Since Tenpenny has the parachute the 
//parachute subroutine now takes over and allows you to skydive as meant by the original game.
0812: AS_actor $PLAYER_ACTOR perform_animation "FALL_FRONT" IFP_file "PED" 1.0 loopA 1 lockX 0 lockY 0 lockF 0 time 250 // versionB 
0812: AS_actor 111@ perform_animation "FALL_FRONT" IFP_file "PED" 1.0 loopA 1 lockX 0 lockY 0 lockF 0 time 250 // versionB 
//This loop waits until Elvis is dead.
:MISSN_16_2310
wait 0 
if 
Actor.Dead(111@)
jf @MISSN_16_2310
//This loop waits until we recover the money from Elvis.
:MISSN_16_2320
wait 0 
00A0: store_actor $PLAYER_ACTOR position_to $TEMPVAR_FLOAT_a $TEMPVAR_FLOAT_b $TEMPVAR_FLOAT_c 
00A0: store_actor 111@ position_to $TEMPVAR_FLOAT_x $TEMPVAR_FLOAT_y $TEMPVAR_FLOAT_z 
//Check distance to grab cash from Elvis.
050A: 3@ = distance_between_XYZ $TEMPVAR_FLOAT_a $TEMPVAR_FLOAT_b $TEMPVAR_FLOAT_c and_XYZ $TEMPVAR_FLOAT_x $TEMPVAR_FLOAT_y $TEMPVAR_FLOAT_z  
if 
3@ < 1.0   
jf @MISSN_16_2320
//Jump to Mission Passed!
jump @MISSN_16_2700

:MISSN_16_PLAYSND
wait 0
if 
03D0:   wav 1 loaded 
jf @MISSN_16_PLAYSND
03D1: play_wav 1 
:MISSN_16_PLAYING
wait 0
if 
03D2:   wav 1 ended 
jf @MISSN_16_PLAYING
040D: unload_wav 1 
return

//You're a LOSER! 
:MISSN_16_2600
//Either you died or got busted and lost the mission.
00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
//This is point to return to the station and retry the mission.
$CRASH_MARKER = Marker.CreateIconAndSphere(16, -1635.8995, 721.0715, 14.6169)
return
              
:MISSN_16_2700
$CRASH_TOTAL_PASSED_MISSIONS += 1 
030C: progress_made += 1 
0394: play_music 1 
Player.ClearWantedLevel($PLAYER_CHAR)
01E3: show_text_1number_styled GXT 'M_PASS' number 20000 time 5000 style 1  
Player.Money($PLAYER_CHAR) += 20000
wait 5000 
return 

:MISSN_16_2720
$ONMISSION = 0 
01BD: $CURRENT_TIME_IN_MS = current_time_in_ms
0164: disable_marker 90@
Model.Destroy(#SHAMAL)
Model.Destroy(#VHMYELV)          
Model.Destroy(#GUN_PARA) 
mission_cleanup 
return 

